package com.qf.demo;

import com.qf.utils.DbUtil;
import com.qf.utils.DbUtil2;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/*
杨威
2021/9/6
10:28
*/
public class Select {

    public static void main(String[] args){}{
        Connection connection = DbUtil2.getConnection();
        PreparedStatement preparedStatement = null;
        ResultSet resultSet = null;
        try {
            preparedStatement = connection.prepareStatement("select * from student where stu_id=?");
            preparedStatement.setInt(1, 1);
            resultSet = preparedStatement.executeQuery();
            while(resultSet.next()){
                int anInt = resultSet.getInt(1);
                String string = resultSet.getString(2);
                System.out.println(anInt+"\t" + string);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            DbUtil2.closeAll(connection, preparedStatement,resultSet );
        }
    }


}
